// pages/taokouling/taokouling.js

var util = require('../../utils/util.js');
var api = require('../../config/api.js');

Page({

    /**
     * 页面的初始数据
     */
    data: {
        pictUrl: "",
        couponShareUrl: "",
        amoy: "￥gwa6cWnp8a6￥",
        flag: true,
        shu1: 0
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let data = wx.getStorageSync("amoy");
        console.log(api.GoodsAmoy);

        this.setData({
            pictUrl: data.pictUrl,
            couponShareUrl: data.couponShareUrl
        })

        if (this.data.couponShareUrl != null || this.data.couponShareUrl !== "") {
            util.request(api.GoodsAmoy, {
                    couponShareUrl: this.data.couponShareUrl,
                }
            ).then(value => {
                console.log(value);
                this.data.amoy = value;
            });

        }


    },


    handleCopy() {
        var that = this;
        this.setData({
            flag: false
        })

        let number = setInterval(args => {
            clearInterval(number);
            if (that.data.flag === false) {
                that.setData({flag: true});
            }
        }, 2000);

        wx.setClipboardData({
            data: this.data.amoy,
            success: res => {
                console.log(res);
            }
        })
    },


})
